function [ A,B,C,D ] = carConst( x0, u0, param )
%CARLIN Summary of this function goes here
%   Detailed explanation goes here
persistent pA pB
if(isempty(pA) || isempty(pB))
    x0=[0;10*sqrt(2);45*pi/180;0;0;0];
    u0=[0;0.00*ones(4,1)];
    %    A = CARA(I,A,B,C,DELTAF,DELTAR,DPSI,DX,DY,G,M,PSI)
    A=carA(param.I,param.a,param.b,param.c,u0(1),0,x0(4),x0(2),x0(1),param.g,param.m,x0(3));
    %    B = CARB(I,A,B,C,DELTAF,DPSI,DX,DY,G,M,SFL,SFR)
    B=carB(param.I,param.a,param.b,param.c,u0(1),x0(4),x0(2),x0(1),param.g,param.m,u0(2),u0(3));
    pA=A;
    pB=B;
else
    A=pA;
    B=pB;
end

A(isnan(A))=0;
B(isnan(B))=0;
C=eye(6);
D=zeros(size(C,1),size(B,2));
end

